package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.MainContentBean;
import com.project.service.IMainContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @author lyl
 * description:主贴相关controller
 */
@RestController
@RequestMapping("mainContent")
public class MainContentController {
    @Autowired
    private IMainContentService iMainContentService;

    @RequestMapping("showMCByPage")
    public PageInfo<MainContentBean> showMCByPage(int pageNo, int themeId, String mcTitle, String username, LocalDate startDate, LocalDate endDate) {
        return iMainContentService.showMCByPage(pageNo, themeId, mcTitle, username, startDate, endDate);
    }

    @RequestMapping("addMC")
    public String addMC(MainContentBean mainContentBean, int userId, int themeId) {
        iMainContentService.addMC(mainContentBean, userId, themeId);
        return "ok";
    }

    @RequestMapping("findMCById")
    public MainContentBean findByMCId(int mainContentId) {
        return iMainContentService.findMCById(mainContentId);
    }
}
